#include "comm.hpp"


int main(){
    // //1.创建key
    // key_t key = getKey();
    // cout << "server key=" << toHex(key) << endl;

    // //2.创建共享内存
    // int shmid = createShm(key, gsize);
    // cout << "server shmid=" << toHex(shmid) << endl;

    // //3.关联共享内存
    // char *start = attachShm(shmid);

    // struct shmid_ds ds;
    // int n = shmctl(shmid, IPC_STAT, &ds);
    // if(n != -1){
    //     cout << "perm: " << toHex(ds.shm_perm.__key) << endl;
    //     cout << "creater pid: " << ds.shm_cpid << " : " << getpid() << endl;
    // }

    // //4.取消关联
    // detachShm(start);


    // //5.删除共享内存
    // delShm(shmid);

    Shm shm1(SERVER);
    char *start = shm1.getStart();

    int n = 0;
    while(n<10){
        cout << "client to server : " << start << endl;
        n++;
        sleep(1);
    }

    return 0;
}